﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_MasterPageAdmin : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Logindiv();
    }
    public void Logindiv()
    {
        try
        {
            if ((Session["User"].ToString() != "") || (Session["User"] != null))
            {
                lblWel.Text = "Welcome:";
                lblUserName.Text = Session["User"].ToString();
                btnLogout.Text = "Logout";
            }
            else
            {
                lblWel.Text = "";
                lblUserName.Text = "";
                btnLogout.Text = "Login";
                Response.Redirect("~/LoginMaster.aspx");
            }
        }
        catch (Exception ex)
        {
            lblWel.Text = "";
            lblUserName.Text = "";
            btnLogout.Text = "Login";
            Response.Redirect("~/LoginMaster.aspx");
        }
    }
    protected void btnLogout_Click(object sender, EventArgs e)
    {
        if (btnLogout.Text == "Logout")
        {
            lblUserName.Text = "";
            lblWel.Text = "";
            Session.Abandon();
            Response.Cookies.Clear();
            btnLogout.Text = "Login";
            Response.Redirect("../LoginMaster.aspx");
        }
        else
        {
            Response.Redirect("../LoginMaster.aspx");
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {

        Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
    }
}
